prepare-root: Rename rootfs variables
authorColin Walters <walters@verbum.org>
Wed, 16 Jul 2025 16:56:49 +0000 (12:56 -0400)
committerColin Walters <walters@verbum.org>
Wed, 16 Jul 2025 17:29:08 +0000 (13:29 -0400)
Prep for moving more functionality there, it's really about
the rootfs, not just composefs.

Signed-off-by: Colin Walters <walters@verbum.org>
src/libostree/ostree-soft-reboot.c
src/libostree/ostree-sysroot-deploy.c
src/libotcore/otcore-prepare-root.c
src/libotcore/otcore.h
src/switchroot/ostree-prepare-root.c

index d4c6e3a41ae42acfdc61ab3fa66879336f04bfa3..2c728a3c1094f0ebf9ef610562e9ff491f204878 100644 (file)
@@ -56,12 +56,12 @@ _ostree_prepare_soft_reboot (GError **error)
     return FALSE;
 
   g_autofree char *kernel_cmdline = read_proc_cmdline ();
-  g_autoptr (RootConfig) composefs_config
+  g_autoptr (RootConfig) rootfs_config
       = otcore_load_rootfs_config (kernel_cmdline, config, TRUE, error);
-  if (!composefs_config)
+  if (!rootfs_config)
     return FALSE;
 
-  if (composefs_config->enabled != OT_TRISTATE_YES)
+  if (rootfs_config->enabled != OT_TRISTATE_YES)
     return glnx_throw (error, "soft reboot not supported without composefs");
 
   GVariantBuilder metadata_builder;
@@ -72,7 +72,7 @@ _ostree_prepare_soft_reboot (GError **error)
 
   // Tracks if we did successfully enable it at runtime
   bool using_composefs = false;
-  if (!otcore_mount_rootfs (composefs_config, &metadata_builder, root_transient, sysroot_path,
+  if (!otcore_mount_rootfs (rootfs_config, &metadata_builder, root_transient, sysroot_path,
                             target_deployment, OTCORE_RUN_NEXTROOT, &using_composefs, error))
     return glnx_prefix_error (error, "failed to mount composefs");
 
index 92176bd77a1922820a298048cc34e59fdf78c4e6..749436bd3148953a20b4d6410d75c9e5ba838932 100644 (file)
@@ -656,12 +656,12 @@ checkout_deployment_tree (OstreeSysroot *sysroot, OstreeRepo *repo, const char *
   // out if it's enabled, but not supported at compile time.
   // However, we don't load the keys here, because they may not exist, such
   // as in the initial deploy
-  g_autoptr (RootConfig) composefs_config
+  g_autoptr (RootConfig) rootfs_config
       = otcore_load_rootfs_config ("", prepare_root_config, FALSE, error);
-  if (!composefs_config)
-    return glnx_prefix_error (error, "Reading composefs config");
+  if (!rootfs_config)
+    return glnx_prefix_error (error, "Reading rootfs config");
 
-  OtTristate composefs_enabled = composefs_config->enabled;
+  OtTristate composefs_enabled = rootfs_config->enabled;
   g_debug ("composefs enabled by config: %d repo: %d", composefs_enabled, repo->composefs_wanted);
   if (repo->composefs_wanted == OT_TRISTATE_YES)
     composefs_enabled = repo->composefs_wanted;
@@ -680,7 +680,7 @@ checkout_deployment_tree (OstreeSysroot *sysroot, OstreeRepo *repo, const char *
   g_auto (GVariantBuilder) cfs_checkout_opts_builder
       = G_VARIANT_BUILDER_INIT (G_VARIANT_TYPE_VARDICT);
   guint32 composefs_requested = 1;
-  if (composefs_config->require_verity)
+  if (rootfs_config->require_verity)
     composefs_requested = 2;
   g_variant_builder_add (&cfs_checkout_opts_builder, "{sv}", "verity",
                          g_variant_new_uint32 (composefs_requested));
index 0a147a67d4483ac7037b5952eb952333e0292f0c..98cb51d5ed3810c8565e8c45b3c77767d49b165b 100644 (file)
@@ -428,7 +428,7 @@ otcore_mount_etc (GKeyFile *config, GVariantBuilder *metadata_builder, const cha
 }
 
 gboolean
-otcore_mount_rootfs (RootConfig *composefs_config, GVariantBuilder *metadata_builder,
+otcore_mount_rootfs (RootConfig *rootfs_config, GVariantBuilder *metadata_builder,
                      gboolean root_transient, const char *root_mountpoint, const char *deploy_path,
                      const char *mount_target, bool *out_using_composefs, GError **error)
 {
@@ -450,7 +450,7 @@ otcore_mount_rootfs (RootConfig *composefs_config, GVariantBuilder *metadata_bui
 #ifdef HAVE_COMPOSEFS
   /* We construct the new sysroot in /sysroot.tmp, which is either the composefs
      mount or a bind mount of the deploy-dir */
-  if (composefs_config->enabled == OT_TRISTATE_NO)
+  if (rootfs_config->enabled == OT_TRISTATE_NO)
     return TRUE;
 
   g_autofree char *sysroot_objects = g_strdup_printf ("%s/ostree/repo/objects", root_mountpoint);
@@ -492,9 +492,9 @@ otcore_mount_rootfs (RootConfig *composefs_config, GVariantBuilder *metadata_bui
       cfs_options.flags = LCFS_MOUNT_FLAGS_READONLY;
     }
 
-  if (composefs_config->is_signed)
+  if (rootfs_config->is_signed)
     {
-      const char *composefs_pubkey = composefs_config->signature_pubkey;
+      const char *composefs_pubkey = rootfs_config->signature_pubkey;
       g_autoptr (GVariant) commit = NULL;
       g_autoptr (GVariant) commitmeta = NULL;
 
@@ -507,7 +507,7 @@ otcore_mount_rootfs (RootConfig *composefs_config, GVariantBuilder *metadata_bui
         return glnx_throw (error, "Signature validation requested, but no signatures in commit");
 
       g_autoptr (GBytes) commit_data = g_variant_get_data_as_bytes (commit);
-      if (!validate_signature (commit_data, signatures, composefs_config->pubkeys, error))
+      if (!validate_signature (commit_data, signatures, rootfs_config->pubkeys, error))
         return glnx_prefix_error (error, "No valid signatures found for public key");
 
       g_print ("composefs+ostree: Validated commit signature using '%s'\n", composefs_pubkey);
@@ -526,12 +526,12 @@ otcore_mount_rootfs (RootConfig *composefs_config, GVariantBuilder *metadata_bui
       expected_digest = g_malloc (OSTREE_SHA256_STRING_LEN + 1);
       ot_bin2hex (expected_digest, cfs_digest_buf, g_variant_get_size (cfs_digest_v));
 
-      g_assert (composefs_config->require_verity);
+      g_assert (rootfs_config->require_verity);
       cfs_options.flags |= LCFS_MOUNT_FLAGS_REQUIRE_VERITY;
       g_print ("composefs: Verifying digest: %s\n", expected_digest);
       cfs_options.expected_fsverity_digest = expected_digest;
     }
-  else if (composefs_config->require_verity)
+  else if (rootfs_config->require_verity)
     {
       cfs_options.flags |= LCFS_MOUNT_FLAGS_REQUIRE_VERITY;
     }
@@ -549,8 +549,8 @@ otcore_mount_rootfs (RootConfig *composefs_config, GVariantBuilder *metadata_bui
   else
     {
       int errsv = errno;
-      g_assert (composefs_config->enabled != OT_TRISTATE_NO);
-      if (composefs_config->enabled == OT_TRISTATE_MAYBE && errsv == ENOENT)
+      g_assert (rootfs_config->enabled != OT_TRISTATE_NO);
+      if (rootfs_config->enabled == OT_TRISTATE_MAYBE && errsv == ENOENT)
         {
           g_print ("composefs: No image present\n");
         }
@@ -562,7 +562,7 @@ otcore_mount_rootfs (RootConfig *composefs_config, GVariantBuilder *metadata_bui
     }
 #else
   /* if composefs is configured as "maybe", we should continue */
-  if (composefs_config->enabled == OT_TRISTATE_YES)
+  if (rootfs_config->enabled == OT_TRISTATE_YES)
     return glnx_throw (error, "composefs: enabled at runtime, but support is not compiled in");
 #endif
   *out_using_composefs = using_composefs;
index 82dfae905f9289af4d2415c0bed81619b4831f2a..070498a21f1502a648f3b7dbfa70f8175390ce44 100644 (file)
@@ -80,7 +80,7 @@ RootConfig *otcore_load_rootfs_config (const char *cmdline, GKeyFile *config, gb
 
 /**
  * otcore_mount_rootfs:
- * @composefs_config: Configuration for composefs.
+ * @rootfs_config: Configuration for root
  * @metadata_builder: (transfer none): GVariantBuilder to add metadata to.
  * @root_transient: Whether the root filesystem is transient.
  * @root_mountpoint: The mount point of the physical root filesystem.
@@ -94,7 +94,7 @@ RootConfig *otcore_load_rootfs_config (const char *cmdline, GKeyFile *config, gb
  *
  * Returns: %TRUE on success, %FALSE on error.
  */
-gboolean otcore_mount_rootfs (RootConfig *composefs_config, GVariantBuilder *metadata_builder,
+gboolean otcore_mount_rootfs (RootConfig *rootfs_config, GVariantBuilder *metadata_builder,
                               gboolean root_transient, const char *root_mountpoint,
                               const char *deploy_path, const char *mount_target,
                               bool *out_using_composefs, GError **error);
index 7eeeb7f49da4c99914a34a5e7f75c2cd39904e43..458997271323eed95dc2f096d5dd15d391e97d76 100644 (file)
@@ -192,14 +192,14 @@ main (int argc, char *argv[])
 
   // We always parse the composefs config, because we want to detect and error
   // out if it's enabled, but not supported at compile time.
-  g_autoptr (RootConfig) composefs_config
+  g_autoptr (RootConfig) rootfs_config
       = otcore_load_rootfs_config (kernel_cmdline, config, TRUE, &error);
-  if (!composefs_config)
+  if (!rootfs_config)
     errx (EXIT_FAILURE, "%s", error->message);
 
   // If composefs is enabled, that also implies sysroot.readonly=true because it's
   // the new default we want to use (not because it's actually required)
-  const bool sysroot_readonly_default = composefs_config->enabled == OT_TRISTATE_YES;
+  const bool sysroot_readonly_default = rootfs_config->enabled == OT_TRISTATE_YES;
   if (!ot_keyfile_get_boolean_with_default (config, SYSROOT_KEY, READONLY_KEY,
                                             sysroot_readonly_default, &sysroot_readonly, &error))
     errx (EXIT_FAILURE, "Failed to parse sysroot.readonly value: %s", error->message);
@@ -231,7 +231,7 @@ main (int argc, char *argv[])
    * However, we only do this if composefs is not enabled, because we don't
    * want to parse the target root filesystem before verifying its integrity.
    */
-  if (!sysroot_readonly && composefs_config->enabled != OT_TRISTATE_YES)
+  if (!sysroot_readonly && rootfs_config->enabled != OT_TRISTATE_YES)
     {
       sysroot_readonly = sysroot_is_configured_ro (root_arg);
       // Encourage porting to the new config file
@@ -263,7 +263,7 @@ main (int argc, char *argv[])
 
   // Tracks if we did successfully enable it at runtime
   bool using_composefs = false;
-  if (!otcore_mount_rootfs (composefs_config, &metadata_builder, root_transient, root_mountpoint,
+  if (!otcore_mount_rootfs (rootfs_config, &metadata_builder, root_transient, root_mountpoint,
                             deploy_path, TMP_SYSROOT, &using_composefs, &error))
     errx (EXIT_FAILURE, "Failed to mount composefs: %s", error->message);
 
@@ -316,7 +316,7 @@ main (int argc, char *argv[])
    * Also, hotfixes are incompatible with signed composefs use for security reasons.
    */
   if (lstat (OTCORE_HOTFIX_USR_OVL_WORK, &stbuf) == 0
-      && !(using_composefs && composefs_config->is_signed))
+      && !(using_composefs && rootfs_config->is_signed))
     {
       /* Do we have a persistent overlayfs for /usr?  If so, mount it now. */
       const char usr_ovl_options[]